package com.yc.RSS.bean;

import lombok.Data;

import java.io.StringWriter;
import java.util.Date;

@Data
public class CommonInformationItem implements java.io.Serializable{
    private String title;  //item的title
    private String txtDate;  //从xml中得到的是String 日期
    private Date date;  // 转为 Date类型

    private String link;  //item的link

    private StringBuffer description; //item的描述

    private String id;

    private String source;  //RSS的源名称

    public void addDescription(String txt){
        this.description.append(txt);
    }

    /***
     *生成 此条item在磁盘上的文件名
     * @return  source_描述的hascode.xml
     */
    public String getFileName(){
        StringWriter writer=new StringWriter();
        writer.append(source);
        writer.append("_");
        writer.append( String.valueOf(description.hashCode())  );
        writer.append(".xml");
        return writer.toString();
    }

}
